/**
 *
 */
package com.storm.lib.bean;

import com.storm.lib.type.ExcelType;
import com.storm.lib.util.ExceptionUtil;
import com.storm.lib.util.StringUtil;


/**
 * 类功能:值Bean,s|as2121代表String "as2121"
 * @author johnny
 * @version 2010-12-1
 */
public class ValueBean {
	public ValueBean(String exp){
		if(StringUtil.isEmpty(exp)){
			obj=null;
		}
		String[] par1 = exp.split("\\|");
		if(par1[0].equals(ExcelType.STRING_TYPE_PREFIX)){
			obj = par1[1];
		}
		else if(par1[0].equals(ExcelType.INTEGER_TYPE_PREFIX)){
			obj = Integer.valueOf(par1[1]);
		}
		else{
			ExceptionUtil.throwInvalidParamException();
		}
	}

	/**
	 *
	 * 方法功能:生成表达式
	 * 更新时间:2010-12-1, 作者:johnny
	 * @param exp
	 */
	public String toExp(){
		if(obj==null){
			return null;
		}
		if(obj instanceof String){
			return "s|"+obj;
		}
		else if(obj instanceof Integer){
			return "i|"+obj;
		}
		else{
			ExceptionUtil.throwInvalidParamException();
		}
		return null;
	}

	private Object obj;

	/**
	 * @return the obj
	 */
	public Object getObj() {
		return obj;
	}

	/**
	 * @param obj the obj to set
	 */
	public void setObj(Object obj) {
		this.obj = obj;
	}


}
